<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       p, div {
            width: 300px;
            height: 30px;
            line-height: 30px;
            color: #fff;
            background-color: pink;
        }
    </style>
</head>

<body>
    <button>显示当前时间</button>
    <div>某个时间</div>
    <p>1123</p>

    <script>

        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        btn.onclick = function() {
            div.innerText = getDate();
        }

        function getDate() {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var dates = date.getDate();
            var arr = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
            var day = date.getDay();
            var time = new Date();
            var hours = date.getHours();
            hours = hours < 10 ? '0'+hours : hours;
            var m = date.getMinutes();
            m = m < 10 ? '0'+m : m;
            var sec = date.getSeconds();
            sec = sec < 10 ? '0'+sec : sec;
            return '今天是：' + year + '年' + month + '月' + dates + '日' + arr[day] + ' '  + hours + ':' + m + ':' + sec;
        }

        var p = document.querySelector('p');
        p.innerText = getDate();
        
    </script>
    
</body>
</html>